package cn.itcast.demo.lock;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

/**
 * @author 虎哥
 */
@Component
public class RedisLockFactory {

    @Autowired
    private StringRedisTemplate redisTemplate;

    /**
     * 获取简单redis锁
     * @param key 锁的名称
     * @return 锁对象
     */
    public SimpleRedisLock getSimpleRedisLock(String key){
        return new SimpleRedisLock(redisTemplate, key);
    }
}
